﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using PPI.Entities;
using PPI.WebConsumer;
using VMind.Global;
namespace PPI.Client.Logic
{
    public class LVendor 
    {
        public static EVendor SelectData(Int32 VendorID)
        {
            DataRow _Datarow = WVendor.SelectData(VendorID).Tables[0].Rows[0];
            EVendor _Vendor = new EVendor();
            
            _Vendor.VendorId = ConvertHelper.ToInt32(_Datarow["VendorID"]);
            _Vendor.Name = ConvertHelper.Tostring(_Datarow["Name"]);
            _Vendor.Status = ConvertHelper.Tostring(_Datarow["Status"]);
            return _Vendor;
        }

        public static List<EVendor> SelectAllIdName()
        {
            DataSet ds = WVendor.SelectAllIdName();
            List<EVendor> _vendorList = new List<EVendor>();
            EVendor _vendor;
            foreach (DataRow  dr in ds.Tables[0].Rows)
            {
                _vendor = new EVendor();
                _vendor.VendorId = ConvertHelper.ToInt32(dr["VendorId"]);
                _vendor.Name = ConvertHelper.Tostring(dr["Name"]);
                _vendor.Projects = LVendor_Project.SelectAllIdNameByVendor(_vendor.Id);
                _vendor.Contacts = LVendor_Contacts.SelectAllIdNameByVendor(_vendor.Id);
                _vendorList.Add(_vendor);
            }
            return _vendorList;
        }
    }
}
